package com.ssm.helong.shop.service.impl;

import com.ssm.helong.shop.Dao.UserDao;
import com.ssm.helong.shop.entity.User;
import com.ssm.helong.shop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;


    @Override
    public String register(String userLoginName, String userLoginPassword) {
        if(userDao.selectByLoginName(userLoginName)!=null){
            return "用户名已经存在";
        }
        User registerUser =new User();
        registerUser.setUserLoginName(userLoginName);
        registerUser.setUserLoginPassword(userLoginPassword);
        registerUser.setUserNickName(userLoginName);
        if(userDao.insertSelective(registerUser)>0){
            return "注册成功";
        }
        return "注册失败";
    }

    @Override
    public String login(String userLoginName, String userLoginPassword) {
      User user= userDao.selectByLoginNameAndPassword(userLoginName,userLoginPassword);
      if(user!=null){
          if(user.getUserIsDeleted()==1){
              return "用户禁止登陆";
          }
          return "success";
      }
        return "ere";
    }
}
